package task4;

import java.io.*;

/**
 * @author Administrator
 */
public class Task4_1 {
    public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        method1("D:\\copy.mp4", "copy1.mp4");
        method2("D:\\copy.mp4", "copy2.mp4");
        method3("D:\\copy.mp4", "copy3.mp4");
        method4("D:\\copy.mp4", "copy4.mp4");
        long end = System.currentTimeMillis();
        System.out.println("共耗时间：" + (end + start) + "毫秒");
    }

    private static void method1(String srcString, String destString) throws IOException{
        FileInputStream fis1=new FileInputStream("D:\\1.mp4");
        FileOutputStream fos1=new FileOutputStream("1.mp4");
        byte[] bys=new byte[1024];
        int len=0;
        while ((len=fis1.read())!=-1){
            fos1.write(bys);
        }
        fos1.close();
        fis1.close();

    }

    private static void method2(String srcString, String destString) throws IOException{
        FileInputStream fis=new FileInputStream("D:\\1.mp4");
        FileOutputStream fos=new FileOutputStream("1.mp4");
        byte[] bys=new byte[1024];
        int len=0;
        while ((len=fis.read())!=-1){
            fos.write(bys,0,len);
        }
        fos.close();
        fis.close();

    }


    private static void method3(String srcString, String destString) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcString));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destString));
        int by = 0;
        while ((by = bis.read()) != -1) {
            bos.write(by);
        }
    }

    private static void method4(String srcString, String destString) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(srcString));
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(destString));
        byte[] bys = new byte[1024];
        int len = 0;
        while ((len = bis.read()) != -1) {
            bos.write(bys,0,len);
        }
        bis.close();
        bos.close();


    }
}
